package com.cms.permission.activity

import android.Manifest
import android.util.Log
import com.alibaba.android.arouter.facade.annotation.Route
import com.android.baselibrary.arouter.ArouterContains
import com.android.baselibrary.base.BaseActivity
import com.android.baselibrary.utils.ToastUtils
import com.cms.permission.R
import com.cms.permission.annotation.PermissionCancel
import com.cms.permission.annotation.PermissionDenied
import com.cms.permission.annotation.PermissionRequest
import com.cms.permission.databinding.ActivityMainPermissionBinding


@Route(path = ArouterContains.PERMISSION)
class PermissionMainActivity : BaseActivity<ActivityMainPermissionBinding>() {
    override fun getLayoutId(): Int = R.layout.activity_main_permission

    override fun initView() {

    }

    override fun initListener() {
      mBinding.tvPermission.setOnClickListener {
        open()
      }
    }
    @PermissionRequest(value = [Manifest.permission.WRITE_EXTERNAL_STORAGE,Manifest.permission.CALL_PHONE],
        200)
    fun open() {
        ToastUtils.show(this,"恭喜您，已获取权限")
        Log.i("TAGasdf", "open: 恭喜您，已获取权限")
    }
    @PermissionDenied
    fun denied(){
        ToastUtils.show(this,"您已拒绝权限，请手动在系统设置中打开权限")
    }
    @PermissionCancel
    fun cancel(){
        ToastUtils.show(this,"很抱歉，权限已被取消")
    }
}